<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>修改密码</title>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.min.js"></script>
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.min.css" rel="stylesheet" />
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/css/app.css?v=042405" rel="stylesheet" />
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/css/SUI.css?v=2">
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/font/iconfont.css">
</head>
<style type="text/css">
		.suiLineInput dl input{margin: 0!important;padding:0;}
		.suiLineInput dl{height: 41px !important}
</style>
<body class="changepwd">
	<form id="form">
	<div class="suiLineInput strong">
		<dl>
			<dt>旧密码</dt>
			<dd><input type="password" name="oldpwd" placeholder="请输入原先密码"></dd>
		</dl>
		<dl>
			<dt>新密码</dt>
			<dd><input type="password" name="newpwd" placeholder="请输入要设置的新密码"></dd>
		</dl>
		<dl>
			<dt>重复密码</dt>
			<dd>
				<input type="password" name="newpwd2" placeholder="请再输入一次新密码">
			</dd>
		</dl>
	</div>
	</form>
	<p class="suiBasicText">Tip：如没有密码，请略过旧密码直接设置新密码并保存</p>
	<button class="sure" id="sure">确定</button>
</body>
</html>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/js/SUI.js"></script>
<script type="text/javascript">
function serialize(form){
 var form=document.getElementById(form);
 var arr={};
	for (var i = 0; i < form.elements.length; i++) {
		    var feled=form.elements[i];
		    switch(feled.type) {
		    case undefined:
		    case 'button':
		    case 'file':
		    case 'reset':
		    case 'submit':
		    break;
		    case 'checkbox':
		    case 'radio':
		    if (!feled.checked) {
		    	break;
		    }
		    default:
		    if (arr[feled.name]) {
			    arr[feled.name]=arr[feled.name]+','+feled.value;
		    }else{
			    arr[feled.name]=feled.value;
		    } 
	    }
 	}
 	return arr
 }
	document.getElementById('sure').addEventListener('tap',function(){
		var form=serialize('form')
		if (!form.newpwd){
			mui.toast('请输入新密码');
			return false;
		}
		if (!form.newpwd2){
			mui.toast('请重复新密码');
			return false;
		}
		if(form.newpwd!=form.newpwd2){
			mui.toast('两次输入密码不一致~')
			return false;
		}
		var that=this
		that.disabled=true
		mui.ajax(window.location.href,{
			data:form,
			dataType:'json',//服务器返回json格式数据
			type:'post',//HTTP请求类型
			timeout:10000,	              
			success:function(res){
				if(res==0){
					mui.alert('网络繁忙,请稍后再试',"提示")
				}else if(res==1){
					mui.alert('修改成功!','提示',function(){
						window.location.href=document.referrer
					})
				}else if(res==2){
					mui.alert('原密码错误!',"提示")
				}else{
					mui.alert('网络繁忙,请稍后再试',"提示")
				}
				that.disabled=false
			},
			error:function(){
				mui.alert('网络繁忙,请稍后再试',"提示")
				that.disabled=false
			}
		});
	})
</script>
{{template "wechat/public/share.html" .}}